package com.gemo.demo.service.impl;

import com.gemo.demo.entiy.News;
import com.gemo.demo.mapper.NewsMapper;
import com.gemo.demo.service.INewsService;
import com.gemo.demo.util.PageUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NewsServiceImpl implements INewsService {
    @Autowired
    private NewsMapper newsMapper;
    @Override
    public PageInfo<News> getNews(int tid, String word,int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<News> newss=newsMapper.select(tid,word);
        return new PageInfo<News>(newss);
    }
    @Override
    public int deleteById(int id) {
        return newsMapper.updateById(id);
    }

    @Override
    public String getDetailById(int id) {
        return newsMapper.selectById(id).getDetail();
    }

    @Override
    public int add(News news) {
        return newsMapper.insert(news);
    }
}
